import os
import sys
from pydub import AudioSegment
from pydub.utils import mediainfo
import galscript

class WolfCommandHeader(galscript.ScriptLine):
    def __init__(self, index, text, processor):
        super().__init__(index, text, processor)

    def process(self):
        # 311： 画面黒く長いフェードアウト
        id = self.find_int(r"(\d+)：")
        result = self.text.split("：", 1)[1].strip()
        self.xml = f'[Command Id=\"{id}\"]{result}[/Command]\n\n'
        pass


def process_file(input_file, assets_dir):
    processor = galscript.ScriptProcessor(input_file, lambda idx,name,processor: WolfCommandHeader(idx,name,processor))
    processor.assets_dir = assets_dir
    processor.process()
    processor.save()

    print(f"处理完成！结果已保存到: {processor.output_file}")

if __name__ == "__main__":
    args = galscript.FileManager()  # 使用imodule中的Args类
    input_file = args.get_str("file")
    assets_dir = args.get_str("assets", "")
    process_file(input_file, assets_dir)